import pytest, time
from Case.python_ui.Common.basepage import Basepage
from Case.python_ui.Pageobject.system_setting_page import SystemSettingPage
from Case.python_ui.Pageobject.login_pages import Loginpages
from Case.python_ui.Test_data.login_data import Logindata
from selenium import webdriver
from Case.python_ui.PageLocate.admin_tech_partner_locator import AdminTechPartnerLocator
from Case.python_ui.PageLocate.admin_business_partner_locator import AdminBusinessPartnerLocator
from selenium.common.exceptions import NoSuchElementException


class AdminBusinessPartnerModule(Basepage):

    # 判断是否包含元素
    def check_contain_str(self, string, except_string):
        if except_string in string:
            assert True
        else:
            assert False, '实际值:' + string + '期望值:' + except_string

    # 校验某个属性值是否符合预期
    def check_attribute(self, real_result, except_result):
        if real_result == except_result:
            assert True
        else:
            assert False, '实际值:' + real_result + '期望值:' + except_result

    # 元素是否存在
    def element_is_exist(self, locate):
        doc = '判断元素是否存在'
        try:
            self.get_element(locate, doc)
        except NoSuchElementException as e:
            return False
        else:
            return True

    # 进入Business Partner->Organization界面
    def enter_business_partner_organization(self):
        time.sleep(2)
        doc = "进入Business Partner->Organization界面"
        for i in range(3):
            try:
                eles = self.get_elements(AdminBusinessPartnerLocator.default_page_expanded, doc)
                for ele in eles:
                    ele.click()
                    time.sleep(1)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_organization_title, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_organization_title, doc)
                break
            except:
                self.refresh_page()
                continue
        time.sleep(5)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_organization_page, doc)

    # 查看Immediate Member页面字段
    def check_immediate_member_pages(self):
        time.sleep(2)
        doc = "查看Immediate Member页面字段"
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_account_email, doc).text, 'Account Email')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_status, doc).text, 'Status')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_user_name, doc).text, 'User Name')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_phone_number, doc).text, 'Phone Number')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_creation_time, doc).text, 'Creation Time (UTC+08:00)')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_actions, doc).text, 'Actions')

    # 查看Invited Customer页面字段
    def check_invited_customer_pages(self):
        time.sleep(2)
        doc = "查看Invited Customer页面字段"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_invited_customer_tab, doc)
        time.sleep(2)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_account_email, doc).text, 'Account Email')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_status, doc).text, 'Status')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_user_name, doc).text, 'User Name')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_customer_type, doc).text, 'Customer Type')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_payment_mode, doc).text, 'Payment Mode')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_inviter, doc).text, 'Inviter')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_invite_time, doc).text, 'Invite Time (UTC+08:00)')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_active_time, doc).text, 'Active Time (UTC+08:00)')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_consumption_mon, doc).text.replace('\n', '').strip(), 'Consumption of This Month ()')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_consumption_year, doc).text.replace('\n', '').strip(), 'Consumption of This Year ()')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_invited_tab_consumption_subtotal, doc).text.replace('\n', '').strip(), 'Consumption of Subtotal ()')

    # 检测Business Partner->Organization页面组织列表搜索功能
    def check_organization_list_search_func(self):
        time.sleep(2)
        doc = "检测Business Partner->Organization页面组织列表搜索功能"
        # 搜索输入框输入有效成员字符
        self.send_keys(AdminBusinessPartnerLocator.organization_list_search_input, 'register', doc)
        # 点击搜索按钮进行搜索操作
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_list_search_btn, doc)
        time.sleep(1)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_list_search_result_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_list_search_result_data, doc).text, 'register07')
        # 清空搜索输入框字符，重新输入无效成员字符进行搜索操作
        self.keyboard_event(AdminBusinessPartnerLocator.organization_list_search_input, doc)
        time.sleep(1)
        self.send_keys(AdminBusinessPartnerLocator.organization_list_search_input, 'register00', doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_list_search_btn, doc)
        time.sleep(1)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_list_search_no_result_data, doc).text, 'No Data')

    # 检测Business Partner->Organization Immediate Member页面组织成员搜索功能
    def check_organization_member_information_search_func(self):
        time.sleep(2)
        doc = "Business Partner->Organization Immediate Member页面组织成员搜索功能"
        # 搜索输入框输入有效成员字符
        self.send_keys(AdminBusinessPartnerLocator.organization_search_input, 's3bp1', doc)
        # 点击搜索按钮进行搜索操作
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_search_btn, doc)
        time.sleep(1)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_search_result_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_search_result_data, doc).text, 's3bp1@qq.com')
        # 清空搜索输入框字符，重新输入无效成员字符进行搜索操作
        time.sleep(1)
        self.keyboard_event(AdminBusinessPartnerLocator.organization_search_input, doc)
        time.sleep(1)
        self.send_keys(AdminBusinessPartnerLocator.organization_search_input, 's3bp100', doc)
        time.sleep(2)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_search_btn, doc)
        time.sleep(1)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_search_no_result_data, doc).text, 'No Data')

    def get_status_name_to_click(self, status_name):
        doc = '获取status名称然后点击'
        status_list = self.get_elements(AdminBusinessPartnerLocator.status_list, doc)
        time.sleep(2)
        for status in status_list:
            if status.text == status_name:
                status.click()
        time.sleep(2)

    # Business Partner->Organization Immediate Member页面成员信息筛选功能检索
    def organization_member_information_filter_func(self):
        time.sleep(2)
        doc = "Business Partner->Organization Immediate Member页面成员信息筛选功能检索"
        # 成员信息筛选功能Status检索Normal,点击ok按钮进行筛选
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_status_filter_btn, doc)
        time.sleep(1)
        self.get_status_name_to_click('Normal')
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_status_filter_ok_btn, doc)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_status_filter_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_status_filter_information, doc).text, 'Normal')

    # Business Partner->Organization Immediate Member页面组织下重置用户密码
    def organization_reset_pwd_func(self):
        time.sleep(2)
        doc = "Business Partner->Organization Immediate Member页面组织下重置用户密码"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_reset_pwd_btn, doc)
        time.sleep(1)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_reset_pwd_box, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_reset_pwd_box_tips1, doc).text, 'User must agree with you to help reset password.')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_reset_pwd_box_tips2, doc).text, 'New password will be sent to user via selected channel(s).')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_reset_pwd_acknowledge_tips, doc).text, 'I acknowledge')
        # 点击勾选I acknowledge按钮，并点击ok
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_reset_pwd_acknowledge_btn, doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_reset_pwd_ok_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_reset_pwd_succcess_tips, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_reset_pwd_succcess_tips, doc).text, 'Reset password successfully.')

    # Business Partner->Organization Immediate Member页面锁定组织下用户
    def organization_member_lock_func(self):
        time.sleep(2)
        doc = "Business Partner->Organization Immediate Member页面锁定组织下用户"
        self.move_mouse_to_element(AdminBusinessPartnerLocator.organization_member_info_menu_btn)
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_member_lock_btn, doc)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_member_lock_box, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_member_lock_box_tips1, doc).text, 'The user was confirmed to be unsecure on system.')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_member_lock_box_tips2, doc).text, 'After locking account, user can not access system from next login try.')
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_member_lock_acknowledge_btn, doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_member_lock_ok_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_member_lock_success_tips, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_member_lock_success_tips, doc).text, 'Locked successfully.')

    # Business Partner->Organization Immediate Member页面解锁组织下用户
    def organization_member_unlock_func(self):
        time.sleep(2)
        doc = "Business Partner->Organization Immediate Member页面解锁组织下用户"
        self.move_mouse_to_element(AdminBusinessPartnerLocator.organization_member_info_menu_btn)
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_member_unlock_btn, doc)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_member_unlock_box, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_member_unlock_box_tips1, doc).text, 'The user was confirmed to be secure on system.')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_member_unlock_box_tips2, doc).text, 'After unlocking account, user can access system from next login try.')
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_member_unlock_acknowledge_btn, doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_member_unlock_ok_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_member_unlock_success_tips, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_member_unlock_success_tips, doc).text, 'Unlocked successfully.')

    # Business Partner->Organization页面编辑成员用户信息
    def organization_edit_member_info_func(self):
        time.sleep(2)
        doc = "Business Partner->Organization页面编辑成员用户信息"
        self.move_mouse_to_element(AdminBusinessPartnerLocator.organization_action_btn)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_action_edit_btn, doc)
        time.sleep(1)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_action_edit_basic_info_itle, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_basic_info_itle, doc).text, 'Basic Information')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_company_name_title, doc).text, 'Company Name:')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_vat_num_title, doc).text, 'VAT number:')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_phone_num_title, doc).text, 'Phone Number')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_post_code_title, doc).text, 'Post Code:')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_state_province_title, doc).text, 'State/Province:')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_city_title, doc).text, 'City:')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_address_title, doc).text, 'Address:')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_business_info_title, doc).text, 'Business Information')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_cashback_level_title, doc).text, 'Cashback Level')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_broker_level_title, doc).text, 'Broker Level')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_product_name_title, doc).text, 'Product Name:')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_cashback_ratio_title, doc).text, 'CashBack Ratio')
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.organization_action_edit_ok_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.organization_action_edit_success_tips, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.organization_action_edit_success_tips, doc).text, 'Edited successfully.')

    # 进入Business Partner->User界面
    def enter_business_partner_user_page(self):
        time.sleep(2)
        doc = "进入Business Partner->User界面"
        for i in range(3):
            try:
                eles = self.get_elements(AdminBusinessPartnerLocator.default_page_expanded, doc)
                for ele in eles:
                    ele.click()
                    time.sleep(1)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_user_title, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_user_title, doc)
                break
            except:
                self.refresh_page()
                continue
        time.sleep(5)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_user_page, doc)

    # Business Partner->User页面用户字段效验
    def check_business_user_member_info(self):
        time.sleep(2)
        doc = "Business Partner->User页面用户字段效验"
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_account_email_title, doc).text, 'Account Email')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_status_title, doc).text, 'Status')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_user_name_title, doc).text, 'User Name')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_phone_number_title, doc).text, 'Phone Number')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_user_group_title, doc).text, 'User Group')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_organization_title, doc).text, 'Organization')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_creation_time_title, doc).text, 'Creation Time (UTC+08:00)')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_actions_title, doc).text, 'Actions')

    # 检测Business Partner->User页面字段搜索功能
    def check_business_user_page_search_func(self):
        time.sleep(2)
        doc = "检测Business Partner->User页面字段搜索功能"
        # 搜索有效的Account Email字段
        self.send_keys(AdminBusinessPartnerLocator.business_user_search_input_box, 'register07', doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_search_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_search_account_email, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_search_account_email, doc).text, 'test.register07New1@gmail.com')
        time.sleep(1)
        self.keyboard_event(AdminBusinessPartnerLocator.business_user_search_input_box, doc)
        # 搜索有效的Phone Number字段
        self.send_keys(AdminBusinessPartnerLocator.business_user_search_input_box, '406778', doc)
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_search_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_search_phone_num, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_search_phone_num, doc).text, '(62)19123850406778')
        time.sleep(1)
        self.keyboard_event(AdminBusinessPartnerLocator.business_user_search_input_box, doc)
        # 搜索无效的Phone Number字段
        self.send_keys(AdminBusinessPartnerLocator.business_user_search_input_box, '111222', doc)
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_search_btn, doc)
        time.sleep(1)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_search_no_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_search_no_data, doc).text, 'No Data')

    # Business Partner->User页面成员信息筛选功能检索
    def check_business_user_page_filter_func(self):
        time.sleep(3)
        doc = "Business Partner->User页面成员信息筛选功能检索"
        # 成员信息筛选功能Status检索Inactive,点击ok按钮进行筛选
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_status_filter_btn, doc)
        time.sleep(1)
        self.get_status_name_to_click('Inactive')
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_status_filter_ok_btn, doc)
        time.sleep(4)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_status_filter_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_status_filter_information, doc).text, 'Inactive')
        # 点击筛选框中的reset重置筛选条件，点击ok按钮查看筛选条件是否重置第一个数据是Normal
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_status_filter_btn, doc)
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_status_filter_reset_btn, doc)
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_status_filter_ok_btn, doc)
        time.sleep(4)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_status_filter_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_status_filter_information, doc).text, 'Normal')

    # Business Partner->User页面下重置用户密码
    def business_user_page_reset_pwd_func(self):
        time.sleep(3)
        doc = "Business Partner->User页面下重置用户密码"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_reset_pwd_btn, doc)
        time.sleep(1)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_reset_pwd_box, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_reset_pwd_box_tips1, doc).text, 'User must agree with you to help reset password.')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_reset_pwd_box_tips2, doc).text, 'New password will be sent to user via selected channel(s).')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_reset_pwd_acknowledge_tips, doc).text, 'I acknowledge')
        # 点击勾选I acknowledge按钮，并点击ok
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_reset_pwd_acknowledge_btn, doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_reset_pwd_ok_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_reset_pwd_succcess_tips, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_reset_pwd_succcess_tips, doc).text, 'Reset password successfully.')

    # Business Partner->User页面锁定组织下用户
    def business_user_member_lock_func(self):
        time.sleep(3)
        doc = "Business Partner->User页面锁定组织下用户"
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_member_info_menu_btn, doc)
        if self.get_element(AdminBusinessPartnerLocator.business_user_member_status_info, doc).text == 'Normal':
            self.move_mouse_to_element(AdminBusinessPartnerLocator.business_user_member_info_menu_btn)
            time.sleep(3)
            self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_lock_btn, doc)
            self.wait_elevisble(AdminBusinessPartnerLocator.business_user_member_lock_box, doc)
            self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_lock_box_tips1, doc).text, 'The user was confirmed to be unsecure on system.')
            self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_lock_box_tips2, doc).text, 'After locking account, user can not access system from next login try.')
            self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_lock_acknowledge_btn, doc)
            self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_lock_ok_btn, doc)
            time.sleep(2)
            self.wait_elevisble(AdminBusinessPartnerLocator.business_user_member_lock_success_tips, doc)
            self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_lock_success_tips, doc).text, 'Locked successfully.')

    # Business Partner->User页面解锁组织下用户
    def business_user_member_unlock_func(self):
        time.sleep(3)
        doc = "Business Partner->User页面解锁组织下用户"
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_member_info_menu_btn, doc)
        self.move_mouse_to_element(AdminBusinessPartnerLocator.business_user_member_info_menu_btn)
        time.sleep(3)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_unlock_btn, doc)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_member_unlock_box, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_unlock_box_tips1, doc).text, 'The user was confirmed to be secure on system.')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_unlock_box_tips2, doc).text, 'After unlocking account, user can access system from next login try.')
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_unlock_acknowledge_btn, doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_unlock_ok_btn, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_member_unlock_success_tips, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_unlock_success_tips, doc).text, 'Unlocked successfully.')

    # Business Partner->User页面用户具体信息overview tab页
    def business_user_member_information_overview_tab(self):
        time.sleep(2)
        doc = "Business Partner->User页面用户具体信息overview tab页"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_account_email, doc)
        time.sleep(1)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_member_specific_info_page, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_basic_info_overview_title, doc).text, 'Basic Information')

    # Business Partner->User页面用户具体信息User Group tab页
    def business_user_member_information_user_group_tab(self):
        time.sleep(2)
        doc = "Business Partner->User页面用户具体信息User Group tab页"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_info_user_group_tab, doc)
        time.sleep(1)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_info_user_group_field, doc).text, 'User Group')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_info_members_field, doc).text, 'Members')

    # Business Partner->User页面用户具体信息Audit tab页
    def business_user_member_information_audit_tab(self):
        time.sleep(2)
        doc = "Business Partner->User页面用户具体信息Audit tab页"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_member_info_audit_tab, doc)
        time.sleep(1)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_info_audit_account_email_field, doc).text, 'Account Email')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_info_audit_event_type_field, doc).text, 'Event Type')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_member_info_audit_remarks_field, doc).text, 'Remarks')

    # 进入Business Partner->Role界面
    def enter_business_partner_role_page(self):
        time.sleep(2)
        doc = "进入Business Partner->Role界面"
        for i in range(3):
            try:
                eles = self.get_elements(AdminBusinessPartnerLocator.default_page_expanded, doc)
                for ele in eles:
                    ele.click()
                    time.sleep(1)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_role_title, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_role_title, doc)
                break
            except:
                self.refresh_page()
                continue
        time.sleep(5)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_role_page, doc)

    # Business Partner->Role页面用户字段效验
    def check_business_role_member_field(self):
        time.sleep(2)
        doc = "Business Partner->Role页面用户字段效验"
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_role_name_title, doc).text, 'Role Name')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_customer_title, doc).text, 'Customer')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_role_type_title, doc).text, 'Role Type')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_creation_time_title, doc).text, 'Creation Time (UTC+08:00)')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_actions_title, doc).text, 'Actions')

    # 检测Business Partner->Role页面字段搜索功能
    def check_business_role_page_search_func(self):
        time.sleep(2)
        doc = "检测Business Partner->Role页面字段搜索功能"
        # 搜索有效的Role Name字段
        self.send_keys(AdminBusinessPartnerLocator.business_role_search_input_box, 'Role', doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_role_search_btn, doc)
        time.sleep(3)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_role_search_role_name, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_search_role_name, doc).text, 'Default Enterprise Role')
        time.sleep(1)
        self.keyboard_event(AdminBusinessPartnerLocator.business_role_search_input_box, doc)
        # 搜索有效的Customer字段
        self.send_keys(AdminBusinessPartnerLocator.business_role_search_input_box, 'dand', doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_role_search_btn, doc)
        time.sleep(3)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_role_search_customer, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_search_customer, doc).text, 'dand')
        time.sleep(1)
        self.keyboard_event(AdminBusinessPartnerLocator.business_role_search_input_box, doc)
        # 搜索无效的Phone Number字段
        self.send_keys(AdminBusinessPartnerLocator.business_role_search_input_box, 'disvxa111', doc)
        time.sleep(1)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_role_search_btn, doc)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_role_search_no_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_search_no_data, doc).text, 'No Data')

    # Business Partner->Role页面用户具体信息overview tab页
    def business_role_member_information_overview_tab(self):
        time.sleep(2)
        doc = "Business Partner->Role页面用户具体信息overview tab页"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_role_role_name, doc)
        time.sleep(2)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_role_member_specific_info_page, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_member_overview_title, doc).text, 'Overview')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_member_overview_role_type_field, doc).text, 'Role Type')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_member_overview_creation_time_field, doc).text, 'Creation Time (UTC+08:00)')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_member_role_allocation_overview_title, doc).text, 'Role Allocation')

    # Business Partner->Role页面用户具体信息Role Permissions tab页
    def business_role_member_information_role_permissions_tab(self):
        time.sleep(2)
        doc = "Business Partner->Role页面用户具体信息Role Permissions tab页"
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_role_member_info_role_permissions_tab, doc)
        time.sleep(1)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_member_info_role_permissions_title, doc).text, 'Role Permissions')

    # 查看用户Overview页面的Role Allocation列表字段
    def business_role_overview_role_allocation_field(self):
        time.sleep(2)
        doc = "查看用户Overview页面的Role Allocation列表字段"
        self.wait_elevisble(AdminBusinessPartnerLocator.business_role_account_email_field, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_account_email_field, doc).text, 'Account Email')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_user_name_field, doc).text, 'User Name')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_phone_num_field, doc).text, 'Phone Number')
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_role_creation_time_field, doc).text, 'Creation Time (UTC+08:00)')

    # 进入Business Partner->User Group界面
    def enter_business_partner_user_group_page(self):
        time.sleep(2)
        doc = "进入Business Partner->User Group界面"
        for i in range(3):
            try:
                eles = self.get_elements(AdminBusinessPartnerLocator.default_page_expanded, doc)
                for ele in eles:
                    ele.click()
                    time.sleep(1)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_tab, doc)
                self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_user_group_title, doc)
                self.click_element(AdminBusinessPartnerLocator.business_partner_user_group_title, doc)
                break
            except:
                self.refresh_page()
                continue
        time.sleep(5)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_partner_user_group_page, doc)

    # 检测Business Partner->User Group页面组织列表搜索功能
    def check_business_user_group_list_search_func(self):
        time.sleep(2)
        doc = "检测Business Partner->User Group页面组织列表搜索功能"
        # 搜索输入框输入有效成员字符
        self.send_keys(AdminBusinessPartnerLocator.business_user_group_list_search_input, 'eee', doc)
        # 点击搜索按钮进行搜索操作
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_group_list_search_btn, doc)
        self.wait_elevisble(AdminBusinessPartnerLocator.business_user_group_list_search_result_data, doc)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_group_list_search_result_data, doc).text, 'eee')
        # 清空搜索输入框字符，重新输入无效成员字符进行搜索操作
        self.keyboard_event(AdminBusinessPartnerLocator.business_user_group_list_search_input, doc)
        time.sleep(1)
        self.send_keys(AdminBusinessPartnerLocator.business_user_group_list_search_input, 'eee00', doc)
        self.move_mouse_to_click_element(AdminBusinessPartnerLocator.business_user_group_list_search_btn, doc)
        time.sleep(1)
        self.check_attribute(self.get_element(AdminBusinessPartnerLocator.business_user_group_list_search_no_result_data, doc).text, 'No Data')














